package com.chi.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chi.dao.AdviseDao;
import com.chi.daoImpl.AdviseDaoImpl;
import com.chi.page.Page;
import com.chi.pojo.Advise;
import com.chi.service.AdviseService;
@Service("adviseservice")
public class AdviseServiceImpl implements AdviseService {
@Autowired
private AdviseDao advi;
	@Override
	public void saveAd(Advise ad) {
		// TODO Auto-generated method stub
		advi.saveAd(ad);
	}

	@Override
	public void deleteAd(Advise ad) {
		// TODO Auto-generated method stub
		advi.deleteAd(ad);
	}
	@Override
	public Advise findById(int id) {
		// TODO Auto-generated method stub
		Advise advise = null;
		try {
			advise = advi.findById(id);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return advise;
	}
	@Override
	public List<Advise> findAll(int pageNo) {
		List<Advise> Advise = new ArrayList<Advise>();
		try {
			Advise = advi.findAll(pageNo);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return Advise;
	}

	@Override
	public Page<Advise> getPage(int pageNo) {
		Page<Advise> page = null;
		try {
			page = advi.getPage(pageNo);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return page;
	}

	@Override
	public int getCount() {
		int in = 0;
		try {
			in = advi.getTotalNum();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return in;
	}



}
